package kosta.model.dao;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import kosta.model.vo.BidVO;
import kosta.model.vo.MemberVO;
import kosta.model.vo.MessageVO;
import kosta.model.vo.SearchVO;
import kosta.model.vo.WishListVO;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class MemberDAOImpl implements MemberDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String findMyPassword(MemberVO vo) {
		return sqlSessionTemplate.selectOne("member.findMyPassword",vo);
	}
	
	  @Override
      public MemberVO login(MemberVO vo) {
              // TODO Auto-generated method stub
              return sqlSessionTemplate.selectOne("member.login",vo);
      }

	  @Override
		public String findMyId(MemberVO vo) {
			
			return sqlSessionTemplate.selectOne("member.findMyId",vo);
		}


	@Override
	public void registerMember(MemberVO vo) {
		System.out.println(vo);
		sqlSessionTemplate.insert("member.memberRegister",vo);
	}

	@Override
	public int idDuplCheck(String id) {
		return sqlSessionTemplate.selectOne("member.idDuplCheck",id);
	}

	@Override
	public MemberVO registerResult(String id) {
		return sqlSessionTemplate.selectOne("member.registerResult",id);
	}

	@Override
	public int emailDuplCheck(String email) {
	
		return sqlSessionTemplate.selectOne("member.emailDuplCheck",email);
	}

	@Override
	public List<BidVO> getMyBidList(SearchVO svo) {
		return sqlSessionTemplate.selectList("member.getMyBidList",svo);
	}

	@Override
	public int getMyBidListCount(SearchVO svo) {
		return sqlSessionTemplate.selectOne("member.getMyBidListCount",svo);
	}

	@Override
	public int getMyAuctionRegisterHistoryCount(SearchVO svo) {
		return sqlSessionTemplate.selectOne("member.getMyAuctionRegisterHistoryCount",svo);
	}

	@Override
	public List getMyAuctionRegisterHistory(SearchVO svo) {
		return sqlSessionTemplate.selectList("member.getMyAuctionRegisterHistory",svo);
	}

	@Override
	public void memberLeave(MemberVO mvo) {
		sqlSessionTemplate.update("member.dropOutMember",mvo);		
	}

	@Override
	public void updateMember(MemberVO mvo) {
		sqlSessionTemplate.update("member.updateMember",mvo);		
	}

	@Override
	public void sendMessage(MessageVO msvo) {
		sqlSessionTemplate.update("member.sendMessage",msvo);				
	}

	@Override
	public List<MessageVO> getMyMessageList(SearchVO svo) {
		return sqlSessionTemplate.selectList("member.getMyMessageList",svo);		
	}

	@Override
	public int getMyMessageCount(SearchVO svo) {
		return sqlSessionTemplate.selectOne("member.getMyMessageCount",svo);
	}

	@Override
	public MessageVO showMessageContent(int messageNo) {
		return sqlSessionTemplate.selectOne("member.showMessageContent",messageNo);
	}

	@Override
	public void updateReadCheck(int messageNo) {
		 sqlSessionTemplate.update("member.updateReadCheck",messageNo);		
	}

	@Override
	public void deleteMessage(HashMap map) {
		 sqlSessionTemplate.update("member.deleteMessage",map);	
	}

	@Override
	public void deleteMessageDB(int messageNo) {
		 sqlSessionTemplate.update("member.deleteMessageDB",messageNo);			
	}

	@Override
	public MemberVO memberLogin(MemberVO vo) {
		return sqlSessionTemplate.selectOne("member.memberLogin",vo);

	}

	@Override
	public void messageLeave(MemberVO mvo) {
		 sqlSessionTemplate.update("member.messageLeave",mvo);
	}


}
